from django.template import Library
from sa import models

register = Library()


@register.inclusion_tag('inclusion/ongoing_projects.html')
def ongoing_projects(request):
    # 拿到正在进行或等待的项目  使用__in查询集过滤器
    # queryset = models.Project.objects.filter(
    #     owner=request.sa, status__in=['Ongoing',])
    queryset = request.sa.join_projects.filter(status='Ongoing').order_by('-id')
    # request 里封装了 request.project
    return {'queryset': queryset, 'request': request}
